package org.lwz.space.dao.impl;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.lwz.space.dao.ArticleDao;
import org.lwz.space.dao.UserDao;
import org.lwz.space.model.Article;
import org.lwz.space.model.ArticleType;
import org.lwz.space.model.User;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by Liaowz on 2015/10/16.
 */
@Repository(value = "articleDao")
public class ArticleDaoImpl extends BaseDaoImpl<Article> implements ArticleDao {

    @Override
    public List<Article> listBy(ArticleType articleType) {
        //TODO: 查询出该文章类型下的所有文章
        Query query = getSession().createQuery("FROM Article where articleType.name = :type");
        query.setParameter("type", articleType.getName());
        return (List<Article>)query.list();
    }

}
